﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SLLottery.Common
{
    public static class MyColor
    {
        public static Color ConvertColor(this string colorName)
        {
            if (colorName.StartsWith("#"))
                colorName = colorName.Replace("#", string.Empty);
            int v = int.Parse(colorName, System.Globalization.NumberStyles.HexNumber);
            return new Color()
            {
                A = Convert.ToByte((v >> 24) & 255),
                R = Convert.ToByte((v >> 16) & 255),
                G = Convert.ToByte((v >> 8) & 255),
                B = Convert.ToByte((v >> 0) & 255)
            };
        }
        public static LinearGradientBrush GetLineBrush()
        {
            //<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            //<GradientStop Color="#FFCCCCCC" Offset="0"/>
            //<GradientStop Color="Black" Offset="1"/>
            //<GradientStop Color="#FFABABAB" Offset="0.457"/>
            //<GradientStop Color="Black" Offset="0.53"/>
            //</LinearGradientBrush>
            LinearGradientBrush brush = new LinearGradientBrush();
            brush.EndPoint = new Point(0.5, 1);
            brush.StartPoint = new Point(0.5, 0);

            GradientStop gs = new GradientStop();
            gs.Color = ConvertColor("#FFCCCCCC");
            gs.Offset = 0;
            brush.GradientStops.Add(gs);

            gs = new GradientStop();
            gs.Color = Colors.Black;
            gs.Offset = 1;
            brush.GradientStops.Add(gs);

            gs = new GradientStop();
            gs.Color = ConvertColor("#FFABABAB");
            gs.Offset = 0.457;
            brush.GradientStops.Add(gs);

            gs = new GradientStop();
            gs.Color = Colors.Black;
            gs.Offset = 0.53;
            brush.GradientStops.Add(gs);

            return brush;
        }
    }
}
